package code.example.zookeeper.apply.config;

import code.example.tool.Log;
import code.example.tool.LogFactory;
import code.example.zookeeper.apply.config.producer.ZKNodeProducer;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;


public class StartProduct {
   private static  Log log = LogFactory.getLog();
    public void start() throws Exception {
        String configFilePath = "classpath:/code/example/zookeeper/apply/config/config.properties";
        DefaultResourceLoader defaultResourceLoader = new DefaultResourceLoader();
        Resource resource =  defaultResourceLoader.getResource(configFilePath);
        ConfigParse configParse = new ConfigParse();
        ConfigNode configNode =  configParse.parse(resource);
        ZKNodeProducer zkNodeProducer = new ZKNodeProducer();
        zkNodeProducer.create(configNode);
    }
    public static void main(String [] args){
        try{
            StartProduct  startProduct  = new StartProduct();
            startProduct.start();
            log.info("config finish");
        }catch (Exception e){
            log.error(e);
        }
    }
}
